package com.usb.qa.java.Kirkov.exam1.model;

import java.io.Serializable;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.util.Random;

public class Product implements Serializable, Comparable{
	@ExamAnno(author="AKirkov", description="class, whose objects' fields completing by elements of xml document")
	public Product(String name, String productionCountry,
			int weight, int price) {
		this.id = rnd.nextInt(1000);
		this.bucketId = bucketId;
		this.name = name;
		this.productionCountry = productionCountry;
		this.weight = weight;
		this.price = price;
	}
	public Product() {
		// TODO Auto-generated constructor stub
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getBucketId() {
		return bucketId;
	}
	public void setBucketId(int bucketId) {
		this.bucketId = bucketId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getProductionCountry() {
		return productionCountry;
	}
	public void setProductionCountry(String productionCountry) {
		this.productionCountry = productionCountry;
	}
	public int getWeight() {
		return weight;
	}
	public void setWeight(int weight) {
		this.weight = weight;
	}
	public int getPrice() {
		return price;
	}
	public void setPrice(int price) {
		this.price = price;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime
				* result
				+ ((productionCountry == null) ? 0 : productionCountry
						.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Product other = (Product) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (productionCountry == null) {
			if (other.productionCountry != null)
				return false;
		} else if (!productionCountry.equals(other.productionCountry))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "Product [id=" + id + ", bucketId=" + bucketId + ", name="
				+ name + ", productionCountry=" + productionCountry
				+ ", weight=" + weight + ", price=" + price + "]";
	}
		
	public int compareTo(Object o) {
		Product tmp=(Product) o;
		if (this.id<tmp.id){
		return -1;}
		else if(this.id>tmp.id)
		{
			return 1;
		}
		return 0;
	}

	Random rnd=new Random();
	private transient int id;
	private int bucketId;
	private String name;
	private String productionCountry;
	private int weight;
	private int price;
}
